-
-
Notifications
You must be signed in to change notification settings - Fork 205
fix(submission): handle missing xml file with digest authentication DEV-1038 #6428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(submission): handle missing xml file with digest authentication DEV-1038 #6428
Conversation
noliveleger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add unit tests
| ) | ||
| with open(submission_path) as sf: | ||
| data = {'xml_submission_file': sf} | ||
| request = self.factory.post(f'/{username}/submission', data={}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you don't pass data here, could you move it in the next block, maybe sf.seek(0) would not be needed at this point?
| auth = DigestAuth('bob', 'bobbob') | ||
| request.META.update(auth(request.META, response)) | ||
| response = self.view(request, username=username) | ||
| self.assertContains(response, 'Successful submission', status_code=201) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use status.HTTP_201_CREATED instead
noliveleger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🗒️ Checklist
#Support Docs Updates, if any<type>(<scope>)<!>: <title> DEV-1234Front endand/orBack endorworkflow📣 Summary
Prevent server errors when clients using Digest authentication send empty submission requests to the openrosa
/<username>/submissionendpoint.📖 Description
Previously, when a client (such as curl using --digest) attempted to submit to
https://kobocat/<username>/submissionfor a form that does not allow anonymous submissions, the first unauthenticated request in the Digest handshake was accepted by the view.Because this initial request contained no body and no authentication header, the view attempted to read a
Nonefile instance, leading to:This caused a 500 error before the client’s second (authenticated) request could be processed.
This PR adds a validation to check whether
xml_fileis missing or empty. When this happens, the server now fails fast with a properOpenRosaResponseBadRequest (400)and a clear, informative error message.👀 Preview steps